package 剑指offer.面试题61;

import 数据结构.链表.ListNode;

public class Solution {
    public ListNode rotateRight(ListNode head, int k) {
        int length = 0;
        ListNode tail = head;
        while(tail.next!=null){
            tail = tail.next;
            length++;
        }
        tail.next = head;
        k = k%length;
        for (int i = 0; i < length - k; i++) {
            tail = tail.next;
        }
        head = tail.next;
        tail.next=null;
        return head;
    }
}
